<?php
namespace Plu\Library\Models\Platform\Seo;

use Phalcon\Mvc\Model,
    Phalcon\Db\Column;

class RoomSeo extends Model {
    public $Id;

    public $CategoryId;

    public $Domain;

    public $RoomId;

    public $PageType;

    public $Title;

    public $Keywords;

    public $Description;

    public $CreateTime;

    public $LastChanged;

    public $Status;

    const TYPE_CHANNEL = 6;

    public function initialize() {
        $this->setReadConnectionService('db.platform.slave');
    }

    public function getSource() {
        return 'RoomSeo';
    }

    static public function getItem($domain, $type) {
        $item = self::findFirst(array(
            "Domain = :domain: And PageType = :type:",
            "bind" => array(
                'domain' => $domain,
                'type'   => $type,
            ),
            "bindTypes" => array(
                'domain' => Column::BIND_PARAM_STR,
                'type'   => Column::BIND_PARAM_INT
            ),
        ));

        if ($item == false) {
            return [];
        } else {
            return $item->toArray();
        }
    }
}
?>
